package cscie160.hw5;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
/**
 * This class is the actual ATMFactory.
 * Create the RMI ready implementation of the factory interface.
 * Designed to return a remote reference to an ATM instance. 
 * @author Michael Melnikov 
*/
public class ATMFactoryImpl extends UnicastRemoteObject implements ATMFactory{
    /**
    * no-args constructor. makes ATMFactory instance.
    */
    public ATMFactoryImpl() throws RemoteException {
        super();
    }
    
    /**
    * makes ATM instance.
    * @return atm ATM.
    */    
    public ATM getATM() throws RemoteException{
        ArrayList<Integer> balanceValues = new ArrayList<Integer>();
        balanceValues.add(0);
        balanceValues.add(100);
        balanceValues.add(500);
        try{
            ATM atm = new ATMImpl(balanceValues);
            //System.out.println(getClass().getName() + " atm=" + atm + " of class \"" + atm.getClass().getName() + "\" created.");
            return atm;
        } catch (ATMException atmex){
            System.out.println(getClass().getName() + " Ex.:" + atmex.getMessage());
            return null;
        }
    }
}